<!DOCTYPE XHTML>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Test Yowl</title>
		<script src="../../deploy/backplanejs-0.6.4/backplane-min.js" type="text/javascript">/**/</script>
		<link rel="stylesheet" href="../../deploy/backplanejs-0.6.4/assets/backplane-min.css" />

		<script src="/assets/display-systray.js" type="text/javascript">/**/</script>

		<script type="text/javascript">

			/*
			* Set up some default settings, for use in testing. These settings would normally come from
			* an external source, and be under the control of the user, but we put them inline so that
			* we can play with them.
			*
			* NOTE: The only differences between this file and 'test-yowl.html' are:
			*
			*   (a) we've simulated the user choosing to set the "Friend logged off" and "Friend twittered"
			*       notifications to display outside the browser, if possible, and;
			*
			*   (b) we've overridden the 'sticky' setting for "Important announdement", so that we don't need
			*       to 'click' it.
			*/

			document.Growl.addUserSettings(
  			{
    			_default: { displayName: "smoke", logging: false },
    			_applicationsList:
      			[
        			{
          			name: "facebook",
          			item: {
            			_notificationsList:
              			[
                			{ name: "Friend logged on", item: { enabled: true, displayName: "plain", priority: "default" } },
                			{ name: "Friend logged off", item: { enabled: "default", displayName: "plain", priority: "default", useExternal: true } },
                			{ name: "Friend twittered", item: { enabled: "default", displayName: "default", priority: "default", useExternal: true } },
                			{ name: "Important announcement", item: { enabled: "default", displayName: "default", isSticky: false } }
              			]//array of notifications
          			}//the actual settings
        			}//the facebook application
      			]//array of registered applications
  			}
			);

			/*
			 * First register with Yowl. We tell it:
			 *
			 * - the application name;
			 * - all the possible notifications we can send;
			 * - each of the notifications that is enabled by default, either by index or name;
			 * - a default image to use for any message that has no image set.
			 *
			 * Note that the notification 'names' are not displayed on the message, but are
			 * used in the management interface, so should be human readable.
			 */

		    document.Yowl.register(
		        "facebook",
		        [ "Friend logged on", "Friend logged off", "Friend twittered", "Important announcement" ],
		        [ 0, 1, 3, "Friend twittered" ],
		        "img/facebook.gif"
		    );


			/*
			 * Functions to display some messages. For each message we pass:
			 *
			 * - the id of the message, as registered;
			 * - the title for the message;
			 * - some fuller text for the message;
			 * - the name of our application, as registered;
			 * - an optional image;
			 * - a flag to indicate whether sticky or not, which can still be
			 *   overridden by the user's settings;
			 * - a priority level, which could still be overridden by the user's settings.
			 */

			var friend = new Array();

      friend[0] = { foreName: "Sam", fullName: "Sam Sethi", image: "img/sam.jpg" };
      friend[1] = { foreName: "Nico", fullName: "Nico Macdonald", image: "img/nico.jpg" };

			setTimeout(testYowl, 4000);

			function friendLoggedOn(friend, delayToLogoff)
			{
			    document.Yowl.notify(
			        "Friend logged on",
			        friend.fullName + " has logged on",
			        friend.foreName + " has just logged on, and since you don't have many friends, you better go talk to him.",
			        "facebook",
			        friend.image,
			        false,
			        0
			    );

				setTimeout(
					function()
					{
					    document.Yowl.notify(
					        "Friend logged off",
					        friend.fullName + " has logged off",
					        friend.foreName + " has just logged off, so now you really are on your own.",
					        "facebook",
					        friend.image,
					        false,
					        0
					    );
					},
					delayToLogoff
				);
			}//friendLoggedOn()

			function friendTwittered(friend, message)
			{
			    document.Yowl.notify(
			        "Friend twittered",
			        friend.foreName + " updated Twitter.",
			        message,
			        "facebook",
			        "img/twitter.gif",
			        false,
			        0
			    );
			}//friendTwittered()

			function testYowl()
			{

			    document.Yowl.notify(
			        "Important announcement",
			        "This is important",
			        "This message won't go away until you click it. It uses 'emergency' style, and the application icon.",
			        "facebook",
			        null,
			        true,
			        "emergency"
			    );

				friendLoggedOn( friend[0], 10000 );
				setTimeout(
					function()
					{
						friendLoggedOn( friend[1], 13000 );
						return;
					},
					3000
				);

				setTimeout(
					function()
					{
						friendTwittered( friend[0], "Fathers day...having lunch." );
						return;
					},
					8000
				);

				setTimeout(
					function()
					{
						friendTwittered( friend[1], "I'm going to a conference." );
						return;
					},
					10000
				);
				setTimeout(testYowl, 20000);
				return;
			}//testYowl()
		</script>
	</head>
  <body>
  </body>
</html>
